/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pckSql;

/**
 *
 * @author 41180283
 */
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Conexao {
 public Connection conectar(){
    
    
    String user = "root";
    String passwd = "administrador";
    String server = "127.0.0.1";
    String port = "3306"; 
    String database = "bdManhattan";
    
    
    
        String url ="jdbc:mysql://" + server + ":" + port + "/" + database;

    try{
    	
      Connection conn = DriverManager.getConnection(url, user, passwd);
     
      return conn;
    }
    catch(SQLException ex){
      System.out.println("SQLException: " + ex.getMessage());
      System.out.println("SQLState: " + ex.getSQLState());
      System.out.println("VendorError: " + ex.getErrorCode());
      return null;
    }
    catch(Exception e){
      System.out.println("Problemas ao tentar conectar com o banco de dados: " + e);
      return null;
    }
  }
}
